package org.sunflower.aliyun.oss;

import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.sunflower.aliyun.AliyunProperties;

/**
 * @description:
 * @author: TanJingyu
 * @create: 2021-10-11 18:53
 **/
@Configuration
@EnableConfigurationProperties(value = AliyunProperties.Oss.class)
@RequiredArgsConstructor
public class OssConfiguration {
    private final AliyunProperties.Oss properties;

    @Bean
    public OSS oss() {
        return new OSSClientBuilder().build(properties.getEndpoint(), properties.getAccessKeyId(), properties.getAccessKeySecret(), configurationOss());
    }

    private ClientBuilderConfiguration configurationOss() {
        ClientBuilderConfiguration configuration = new ClientBuilderConfiguration();
//        configuration.setConnectionTimeout();
//        configuration.setRequestTimeout();
//        configuration.set...

        return configuration;
    }
}
